<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('留言板')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
        <div class="col-md-12">
            <div class="form-group">
                <label class="col-sm-1 control-label">我要留言：</label>
                <div class="col-sm-11">
                    <textarea type="text" name="" id="message" class="form-control" placeholder="请输入文本"></textarea>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-12 col-sm-offset-3">
                    <button type="submit" class="btn btn-primary" onclick="commitMessage()">提交</button>
                </div>
            </div>
        </div>
    </div>

</div>

<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var removeFlag = [[${@permission.hasPermi('monitor:job:remove')}]];
    var datas = [[${@dict.getType('sys_job_group')}]];
    var prefix = ctx + "system/board";

    $(function () {
        var options = {
            url: prefix + "/list",
            sortName: "createTime",
            sortOrder: "desc",
            modalName: "任务",

            columns: [
                {
                    title: '留言板',
                    align: 'left',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push(
                            '    <div class="form-group">\n' +
                            '        <label class="col-sm-2 control-label">' + row.userName + '</label>\n' +
                            '        <div class="col-sm-8">\n' +
                            '            <p class="form-control-static">留言：' + row.message + '</p>\n' +
                            '        </div>\n' +
                            '        <div class="col-sm-2">\n' +
                            '            <p class="form-control-static">时间：' + row.updateTime + '</p>\n' +
                            '        </div>\n' +
                            '    </div>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);

        $(".fixed-table-pagination").remove()

    });

    /* cron表达式生成 */
    function commitMessage(eid, opt) {

        var message = $('#message').val();
        if (message == null||"" === $.trim(message)) {
            return;
        }
        var messageBody = new Object();
        messageBody.message = message;
        $.ajax({
            url: prefix + "/add",
            type: "POST",
            dataType: "json",
            contentType: 'application/json',
            data: JSON.stringify(messageBody),
            success: function (data) {
                console.log(data);
                window.location.reload();
            }
        });
    }

</script>
</body>
</html>